<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-CN">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="aa" uri="/WEB-INF/tld/ajaxanywhere.tld" %>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>jsp</title>
    <script src="/webjars/jquery/3.5.1/jquery.js"></script>
    <script src="/aa.js"></script>
</head>
<body>
<table>
    <thead>
    <th>选择</th>
    <th>ID</th>
    <th>NAME</th>
    <th>CREATE_DATE</th>
    </thead>
    <tbody>
    <c:forEach var="o" items="${list}" varStatus="s">
        <tr>
            <td><input type="radio" name="check_dialog" id="${o.id}" value="${o.id}"/></td>
            <td>${o.id}</td>
            <td>${o.name}<input type="hidden" id="${o.id}_name" value="${o.name}"/></td>
            <td>${o.createDate}<input type="hidden" id="${o.id}_date" value="${o.createDate}"/></td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<button onclick="updateParent()">确定</button>
</body>
<script type="text/javascript">
    function updateParent() {
        //获取radio选中的值
        const id = $("input[name='check_dialog']:checked").val()
        const name = $("#"+id+"_name").val()
        const date = $("#"+id+"_date").val()
        //获取父窗口元素
        let parent = $(window.opener.document)
        parent.find("#parent_id").val(id)
        parent.find("#parent_name").val(name)
        parent.find("#parent_date").val(date)
        window.opener.closeDialog()
    }


</script>

</html>
